package cn.xfdzx.android.apps.shop.adapter;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.HomeSearchRetailGoodsBean;
import cn.xfdzx.android.apps.shop.bean.SearchShopBean;
import cn.xfdzx.android.apps.shop.util.ImageGlideUtil;
import cn.xfdzx.android.apps.shop.widget.CornerImageView;

/**
 * Creator: zf.
 * Date: 2020/9/24.
 * Description:零售-搜索店铺列表适配器-店铺活动标签列表.
 */
public class SearchGoodsListRetailLableAdapter extends BaseQuickAdapter<HomeSearchRetailGoodsBean.DataBean.GoodsBean.LabelBean, BaseViewHolder>  {
    private List<HomeSearchRetailGoodsBean.DataBean.GoodsBean.LabelBean> labelBeans;
    private OnItemOnClickListener onItemOnClickListener;
    private int oldPosition = -1;
    public SearchGoodsListRetailLableAdapter(@Nullable List<HomeSearchRetailGoodsBean.DataBean.GoodsBean.LabelBean> data) {
        super(R.layout.item_searchgoods_lable, data);
        this.labelBeans = data;
    }

    @Override
    public void setData(int index, @NonNull HomeSearchRetailGoodsBean.DataBean.GoodsBean.LabelBean data) {
        super.setData(index, data);
    }


    @Override
    protected void convert(final BaseViewHolder viewHolder, final HomeSearchRetailGoodsBean.DataBean.GoodsBean.LabelBean date) {
        TextView tv_lable = viewHolder.getView(R.id.tv_lable);

        tv_lable.setText(date.getTitle());

        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
    }
    public void clearDatas(){
        mData.clear();
        notifyDataSetChanged();
    }
    public void refreshDatas(List<HomeSearchRetailGoodsBean.DataBean.GoodsBean.LabelBean> list){
        super.replaceData(list);
        this.labelBeans = list;
    }

    public void setItemClickListener(OnItemOnClickListener listener){
        this.onItemOnClickListener = listener;
    }

    public interface OnItemOnClickListener {
        void onItemClick(int position, int oldPosition);
    }
}
